<template>
	<view class="popup-box">
		<uni-popup ref="popup" :type="type" :background-color="backgroundColor" :customClass="'bgF '+customClass" :borderRadius="type=='bottom' ? '10px 10px 0 0' :'16rpx'">
			<view v-if="isSlot" class="contetn">
				<slot></slot>
			</view>
			<view v-else class="contetn mo" :style="{background:contentBG}">
				<image v-if="title" :src="$img_path('/course/city_1.png')" mode="widthFix"></image>
				<view class="title" v-if="title">
					{{title}}
				</view>
				<view class="con-text">
					<slot></slot>
				</view>
				<view class="btn" v-if="isBtn">
					<button @click="cancel" v-if="isCancel">{{cancelText||'取消'}}</button>
					<button @click="confirm">{{confirmText||'确定'}}</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name:"popup",
		props:{
			type:{
				type:String,
				default:'center'
			},
			isSlot:{
				type:Boolean,
				default:false
			},
			title:{
				type:String,
				default:''
			},
			confirmText:{
				type:String,
				default:''
			},
			cancelText:{
				type:String,
				default:''
			},
			isBtn:{
				type:Boolean,
				default:true
			},
			isCancel:{
				type:Boolean,
				default:true
			},
			customClass:{
				type:String,
				default:''
			},
			backgroundColor:{
				type:String,
				default:'#FFFFFF'
			},
			contentBG:{
				type:String,
				default:'#FFFFFF00'
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			open(){
				this.$refs.popup.open()
			},
			close(){
				this.$refs.popup.close()
			},
			
			cancel(){
				this.$emit('cancel')
				this.close()
			},
			confirm(){
				this.$emit('confirm')
			}
		}
	}
</script>

<style lang="scss" scoped>
.popup-box{
	.contetn{
		
		&.mo{
			width: 640rpx;
			// height: 340rpx;
			position: relative;
			// padding: 40rpx 42rpx 48rpx;
			box-sizing: border-box;
			border-radius: 16rpx;
			&>image{
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				left: 0;
				z-index: 0;
			}
			.title{
				position: relative;
				z-index: 9;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 34rpx;
				color: #333333;
				line-height: 48rpx;
				text-align: center;
				font-style: normal;
				text-transform: none;
			}
			
			.con-text{
				position: relative;
				z-index: 9;
				width: 100%;
				// min-height: 170rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
			}
			.btn{
				display: flex;
				align-items: center;
				justify-content: center;
				border-top: 1rpx solid rgba(0, 0, 0, 0.10);
				button{
					width: 50%;
					height: 112rpx;
					border-radius: 41rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 34rpx;
					color: #999999;
					line-height: 112rpx;
					text-align: center;
					font-style: normal;
					text-transform: none;
					background-color: #FFFFFF;
					border-radius: 0 0 0 16rpx;
					&::after{
						border: none;
					}
					&:last-child{
						font-weight: bold;
						color: #FFFFFF;
						background: linear-gradient( 127deg, #FFA233 0%, #FB4C4C 100%);
						border-radius: 0 0 16rpx 0;
						// margin-left: 20rpx;
						border-left: 1rpx solid rgba(0, 0, 0, 0.10);
					}
				}
			}
		}
	}
}

</style>